package com.yanqu.road.server.cmd.activity.jiuzhou;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.jiuzhou.CrossJiuZhouProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.jiuzhou.CrossJiuZhouMgr;
import com.yanqu.road.server.manager.activity.jiuzhou.activity.CrossJiuZhouActivity;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = CrossProtocol.C_JIU_ZHOU_GAME_SEND_ABILITY_TO_CROSS, desc = "九州棋局活动发送赚钱给跨服")
public class CrossUploadGameServerCmd extends CrossCommand {

    private int activityId;

    private List<String> abilityList = new ArrayList<>();

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossJiuZhouProto.UploadUserAbilityMsg speedMsg = CrossJiuZhouProto.UploadUserAbilityMsg.parseFrom(packet.getBytes());
        activityId = speedMsg.getActivityId();
        abilityList = speedMsg.getAbilityList();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossJiuZhouActivity activity = CrossJiuZhouMgr.getActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_JIU_ZHOU_ACTIVITY_NOT_EXIST;
            return;
        }
        activity.addGameUploadAbility((int) serverId, abilityList);
    }

    @Override
    public void sendData() {

    }
}
